import mongoDB from '../mongodb';
import $ from '../utils';

module.exports.SetAdmire = async function (req,res){
    let admire = await  mongoDB.mongoFunc.findData({"daily_id":req.body.dailyId,"username":req.body.username},'f_message_admire');
    if(admire.length>0){
        res.send(JSON.stringify({"status":'0',"msg":'请勿重复点击',"dataset":[]}));
        return;
    }
    let insertData = {"username":req.body.username,'createTime':req.body.createTime,
        'serverTime':$.base.currentTime(),'daily_id':req.body.dailyId,'user_id':req.body.userId}


    let result = await mongoDB.mongoFunc.insertData(insertData,'f_message_admire');
    if(result){
        res.send(JSON.stringify({"status":'1',"msg":'点赞成功',"dataset":[]}));
    }else{
        res.send(JSON.stringify({"status":'0',"msg":'点赞失败',"dataset":[]}));
    }

}